Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(E2E): Enable e2e tests to run in different networks based on chain spec #2403

Open
wants to merge 59 commits into
base: main
Choose a base branch
from

Conversation

nidhi-singh02
Copy link
Contributor

@nidhi-singh02 nidhi-singh02 commented Jan 23, 2025

As part of the change set, we will be able to spin up different networks on the basis of chain ID and the chain spec name combination each in its own kurtosis enclave and run the tests.

The instructions to add your tests is given in README.md.

This is the just the foundation of making the e2e tests customizable and being able to run different specs as part of our e2e suite.

Note : Currently only devnet is supported. I see hardcoding of chainspec in few tests, needs to be refactored.

nidhi-singh02 and others added 24 commits January 9, 2025 11:01
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 0% with 378 lines in your changes missing coverage. Please review.

Project coverage is 32.04%. Comparing base (5476afd) to head (3730fa9).

Files with missing lines Patch % Lines
testing/e2e/suite/setup.go 0.00% 302 Missing ⚠️
testing/e2e/suite/suite.go 0.00% 66 Missing ⚠️
testing/e2e/suite/options.go 0.00% 8 Missing ⚠️
testing/e2e/config/defaults.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2403      +/-   ##
==========================================
- Coverage   32.27%   32.04%   -0.24%     
==========================================
  Files         350      351       +1     
  Lines       15636    15752     +116     
  Branches       20       20              
==========================================
  Hits         5047     5047              
- Misses      10226    10342     +116     
  Partials      363      363              
Files with missing lines Coverage Δ
testing/e2e/config/config.go 0.00% <ø> (ø)
testing/e2e/config/defaults.go 0.00% <0.00%> (ø)
testing/e2e/suite/options.go 0.00% <0.00%> (ø)
testing/e2e/suite/suite.go 0.00% <0.00%> (ø)
testing/e2e/suite/setup.go 0.00% <0.00%> (ø)

@nidhi-singh02 nidhi-singh02 self-assigned this Jan 23, 2025
@nidhi-singh02 nidhi-singh02 changed the title feat(E2E): Allow tests to run in different networks - WIP feat(E2E): Enable e2e tests to run in different networks based on chain spec Jan 29, 2025
@nidhi-singh02 nidhi-singh02 marked this pull request as ready for review January 29, 2025 09:47
@nidhi-singh02 nidhi-singh02 requested a review from a team as a code owner January 29, 2025 09:47
Note: The default chainID for this local network is 80087, which is our dev network configuration. To make changes to the 80087 chain spec used, modify parameters [here](https://github.com/berachain/beacon-kit/blob/main/config/spec/devnet.go#L40).

## Configure the default network configuration
To change the chainID, modify the `ChainID` field in the `NetworkConfiguration` struct in `defaultNetworkConfiguration`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we default to mainnet chain spec in beacond - feels unintuitive to have the default for tests be devnet. Perhaps worth renaming

//nolint:gochecknoglobals // it's a default value
var (
// defaultChainID is the default chain ID for the network.
defaultChainID = 80087
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be const given that they are not mutated?

@@ -57,7 +57,11 @@ type ValidatorTestStruct struct {
// TODO:
// 1) Add staking tests for adding a new validator to the network.
// 2) Add staking tests for hitting the validator set cap and eviction.
func (s *BeaconKitE2ESuite) TestDepositRobustness() {
func (s *BeaconKitE2ESuite) runDepositRobustness() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems unintuitive to have tests not be named as such - affects readability

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also my IDE doesn't let me run this test individually now

networks map[string]*NetworkInstance // maps chainSpec to network
testSpecs map[string]ChainSpec // maps testName to chainSpec
testFuncs map[string]func() // maps test names to test functions
mu sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand on the reasoning for the mutex? it seems the write lock is only in RegisterTest which doesn't seem to be called concurrently

To add your tests, you need to do the following:
1. Create a new file in the `testing/e2e/` directory.
2. Add your tests in here like how it is done in `runBasicStartup()`
3. Register your tests in `TestRunE2E()`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we can avoid this registration?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@rezbera rezbera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An approach to avoid explicit registration outside of the test is to have each test be "aware" of the chainspec it supports, so that I can look at a test and immediately know what chain spec it's supposed to run on. It would also allow me to run the test directly, without running the whole suite from my IDE (Goland). A problem with "registration" based approaches is also forgetting to register.

Example

func (s *BeaconKitE2ESuite) TestDepositRobustness() {	
	s.Logger().Info("Running Deposit Robustness on devnet")
	network, chainSpec := s.SetForNetwork("devnet")

SetForNetwork would effectively run t.Skip() if the test harness is attempting to run the test on a chain spec it doesn't support.

I was initially confused about the modularity goals we aimed to achieve but to be explicit, the user story is as follows:

  • I want to be able to run tests that are opinionated for a particular chainspec.

We are NOT trying to do the following:

  • Run the same test against multiple chainspecs.

@calbera
Copy link
Contributor

calbera commented Feb 5, 2025

+1 to Rez's comment. Some things we should try fixing:

  • currently broken -- if I try changing just 1 test to run on mainnet (and keep the others on devnet) the mainnet fails to startup.
  • reminder -- we want to ideally run the different chains in parallel
  • let's break up this PR into smaller PRs, something like:
    1. the refactor to just the suite which includes running multiple chains
    2. the setup of each of the e2e tests (as Rez mentioned above)
    3. the ability to run each of those chains in parallel

@nidhi-singh02
Copy link
Contributor Author

Will address the review comments/resume here once the node api endpoints for validators is complete, which is priority rn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants